package com.example.controller;

import com.alibaba.fastjson.JSON;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Stream;

@Component
public class Consume {

    @RabbitListener(queues = {"consumeA"})
    @RabbitHandler
    public void rabbitlistner(Channel channel, Message message,String msg) throws IOException {
        List<Student> objects = JSON.parseArray(msg, Student.class);
        for (Student object : objects) {
            System.out.println(object);
        }
        channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
    }
}
